package com.word.app.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.word.app.pojo.NormWord;
import com.word.app.pojo.dto.BaseRemReq;
import com.word.app.service.NormWordService;
import com.word.app.mapper.NormWordMapper;

import java.util.*;

import org.springframework.stereotype.Service;

/**
* @author 311
* @description 针对表【normWord】的数据库操作Service实现
* @createDate 2022-06-16 12:13:09
*/
@Service
public class NormWordServiceImpl extends ServiceImpl<NormWordMapper, NormWord>
    implements NormWordService{

    @Override
    public List<NormWord> testQuery(NormWord word) {
        return this.baseMapper.testQuery(word);
    }

    @Override
    public void addRememberColumn(String uid) {
        this.baseMapper.addRememberColumn(uid);
    }

    @Override
    public void deleteRememberColumn(String uid) {
        this.baseMapper.deleteRememberColumn(uid);
    }

    @Override
    public boolean isExistRememberColumn(String uid) {
        return this.baseMapper.isExistRememberColumn("USER"+uid)!=null;
    }

    @Override
    public List<NormWord> queryRemember(String uid, boolean remembered) {
        return this.baseMapper.queryRemember(uid, remembered);
    }

    @Override
    // public void updateRemember(String uid, List<Integer> idxes, boolean remembered) {
    //     this.baseMapper.updateRemember(uid, idxes.toString().replace('[', '(').replace(']', ')'), remembered);
    // }
    public void updateRemember(BaseRemReq<List> req) {
        BaseRemReq<String> reqString = new BaseRemReq<String>();
        reqString.setUid(req.getUid());
        reqString.setRemembered(req.isRemembered());
        reqString.setParams(req.getParams().toString().replace('[', '(').replace(']', ')'));
        this.baseMapper.updateRemember(reqString);
    }

    @Override
    public IPage<NormWord> queryRememberByPage(Page<NormWord> page, BaseRemReq<NormWord> req) {
        // return this.baseMapper.queryRememberByPage(page, word);
        return this.baseMapper.queryRememberByPage(page, req);
    }
    

}




